
//
//  TBBaseTableViewController.swift
//  新浪微博
//
//  Created by bin on 16/1/23.
//  Copyright © 2016年 XMG. All rights reserved.
//

import UIKit

class TBBaseTableViewController: UITableViewController {

    var isLogin = TBUserAccount.isLogin()
    var vistorView: TBVistorView = {
       return TBVistorView.VistorView()
    }()
    override func loadView() {
        
        isLogin ? super.loadView() : loadVisitorView()
    }
    
    
    func loadVisitorView(){
        
        vistorView.registerBtn.addTarget(self, action: Selector("reigisterClicked:"), forControlEvents: .TouchUpInside)
        vistorView.loginBtn.addTarget(self, action: Selector("LoginClicked:"), forControlEvents: .TouchUpInside)
        view = vistorView
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: Selector("reigisterClicked:"))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: Selector("LoginClicked:"))
    }
    
    @objc private func reigisterClicked(btn: UIButton){
        
        
    }
    
    @objc private func LoginClicked(btn: UIButton){
        let loginVC = UIStoryboard.init(name: "TBLoginViewController", bundle: nil).instantiateInitialViewController()!
        presentViewController(loginVC, animated: true, completion: nil)
    }
}
